home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.demo_apps;
- import sub_arctic.lib.listbox;
- import sub_arctic.input.event;
- import sub_arctic.input.callback_object;
- import sub_arctic.lib.manager;
- import sub_arctic.lib.interactor;
-
- import java.util.Vector;
-
- /**
- * This is a special subclass of the listbox for dealing with our
- * todo list. It is primarly used for handling the special cases of
- * double clicks and drags.
- */
- public class todo_listbox extends listbox implements callback_object{
- /*
- * Ref to the applet.
- */
- protected mail_test _applet;
- /**
- * This class assumes that you will constrain its size and position,
- * so we just give a bogus value to the real listbox knowing you'll
- * override it.
- */
- public todo_listbox(mail_test applet) {
- super(100,100 /*bogus size*/, true /* single selection */, null);
- /* set the callback object to be this ... can't do this in the
- super() call as we can't reference this yet */
- set_callback_obj(this);
- /* set the draggability to true */
- set_allow_dragging(true);
- _applet=applet;
- }
- /**
- * We got a double click, lets deal with it.
- */
- public void handle_double_click() {
- todo_list_element tle;
- Vector contents;
-
- /* we need to tell that item that we want him to put
- the big message back */
- tle=(todo_list_element)focused_raw();
- /* make sure there is a focused on item... */
- if (tle==null) {
- return;
- }
- tle.restore_message();
- /* now remove him from the list */
- contents=contents_raw();
- contents.removeElement(tle);
- set_contents(contents);
- }
- /**
- * This is called by other parts of the system when they
- * want to insert at an object at a given Y coordinate.
- */
- public void insert_at_point(message msg, int y,int x_store, int y_store) {
- int index,i;
- Vector contents=contents_raw(),new_contents=new Vector();
- todo_list_element tle;
-
- /* build the item */
- tle=new todo_list_element(msg, _applet, x_store, y_store);
- /**
- * Convert Y to an index
- */
- index=index_for_screen_point(y);
- /* is it out of bounds or the last child? */
- if ((index==-1) ||
- (_child_display.num_children()==index) ||
- (contents.size()==0)) {
- /* just put it on the end */
- contents.addElement(tle);
- set_contents(contents);
- return;
- }
- /* they put it in the middle */
- for (i=0; i<contents.size(); ++i) {
- new_contents.addElement(contents.elementAt(i));
- /* is it our target? */
- if (i==index) {
- new_contents.addElement(tle);
- }
- }
- /* set the contents to their new value */
- set_contents(new_contents);
- }
- public void callback(interactor from_obj,
- event evt,
- int callback_num,
- Object callback_info) {
-
- if (callback_num==listbox.DOUBLE_CLICK) {
- handle_double_click();
- }
- if (callback_num==listbox.DRAG) {
- System.out.println("Handle Drag");
- }
- }
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-